class Solution:
    def isUgly(self, num: int) -> bool:
        while num:
            if num % 2 == 0:
                num = num // 2
            else:
                break
        while num:
            if num % 3 == 0:
                num = num // 3
            else:
                break
        while num:
            if num % 5 == 0:
                num = num // 5
            else:
                break
        return num == 1


if __name__ == '__main__':
    so = Solution()
    m = [1, 2, 1, 3, 2, 5]
    r = so.singleNumber(m)
    print(r)
